import request from '_utils/request'

// 封装请求   商品分类结构
const fetchCates = (params = {}) => {
  return request.get('/shop/goods/category/all', { params })
}

// 请求轮播接口
const fetchBanner = (params = {}) => request.get('/banner/list', { params })

// 获取商品列表
const fetchItems = (params = {}) => request.post('/shop/goods/list/v2', params)
// 请求商品详情
const fetchDetail = (params = {}) => request.get('/shop/goods/detail', { params })
// 用户注册
const onRegister = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const onLogin = (params = {}) => request.post('/user/username/login', params)
// 加入购物车
const addCart = (params = {}) => request.post('/shopping-cart/add', params)
// 读取购物车
const fetchCatesInfo = (params = {}) => request.get('/shopping-cart/info', { params })
// 修改购物车商品数量
const addItemNumber = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
// 删除商品
const delitems = (params = {}) => request.post('/shopping-cart/remove', params)
// 修改购物车 选中状态
const setItemSelect = (params = {}) => request.post('/shopping-cart/select', params)
// 获取默认收货地址
const getDefaultContact = (params = {}) => request.get('/user/shipping-address/default/v2', { params })
//添加收货地址
const   addComtant =  (params = {}) => request.post('/user/shipping-address/add', params)
//联系人列表
const fetchContactLists = (params = {}) => request.post('/user/shipping-address/list/v2', params)
//收货地址详情
const fetchContactDetail =  (params = {}) => request.get('/user/shipping-address/detail/v2', { params })
//修改收货地址
const updateContact = (params = {}) => request.post('/user/shipping-address/update', params)
export {
  fetchCates,
  fetchBanner,
  fetchItems,
  fetchDetail,
  onRegister,
  onLogin,
  addCart,
  fetchCatesInfo,
  addItemNumber,
  delitems,
  setItemSelect,
  getDefaultContact,
  addComtant,
  fetchContactLists,
  fetchContactDetail,
  updateContact
}
